package com.beaut.project.control;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.beaut.project.service.ExcelService;
import com.beaut.project.service.FinanceService;
import com.beaut.project.service.WareHouseService;
import com.beaut.project.util.ExcelView;

/**
 * 导出
 * @author xf
 *
 */
@Controller
@RequestMapping("/excel")
public class ExcelController extends BaseControl{
	@Autowired 
	private ExcelService excelService; 
	@Autowired 
	private WareHouseService warehouseService; 
	
	/**
	 * 分包借款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listFinanceDeptLogExcel", method = RequestMethod.GET)
	public  void listFinanceDeptLogExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("type_info", "类别");
		tableTitleMap.put("before_money", "交易前金额");
		tableTitleMap.put("money", "本次发生额");
		tableTitleMap.put("afterMoney", "交易后余额");
		tableTitleMap.put("summary", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listFinanceDeptLog(map);
		String fileName = "部门账户往来明细";
		String sheetName = "部门账户往来明细";
		String title = "部门账户往来明细";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 2000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 10000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 分包借款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listNewAdvances", method = RequestMethod.GET)
	public  void listNewAdvances(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("fb_advances", "班组");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("sumMoney", "借款款金额");
		tableTitleMap.put("on_money", "本金");
		tableTitleMap.put("rate", "利率");
		tableTitleMap.put("lx", "利息");
		tableTitleMap.put("already_money", "已还金额");
		tableTitleMap.put("person_name", "经办人");
		tableTitleMap.put("status_desc", "当前状态");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listNewAdvances(map);
		String fileName = "分包商借款";
		String sheetName = "分包商借款单";
		String title = "分包商借款单";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 2000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 4000);
			sheet.setColumnWidth(8, 4000);
			sheet.setColumnWidth(9, 30000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 员工借款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listEmployee", method = RequestMethod.GET)
	public  void listEmployee(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("employee_name", "员工名称");
		tableTitleMap.put("title", "标题");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("money", "借款金额");
		tableTitleMap.put("already_money", "已还金额");
		tableTitleMap.put("status_desc", "当前状态");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listEmployee(map);
		String fileName = "员工还款单";
		String sheetName = "员工还款单";
		String title = "员工还款单";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 2000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 30000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 公共报销导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listFinanceCommonsExcel", method = RequestMethod.GET)
	public  void listFinanceCommonsExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("user_name", "申请人");
		tableTitleMap.put("operation_time", "日期");
		tableTitleMap.put("money", "金额");
		tableTitleMap.put("name", "所属公司");
		tableTitleMap.put("is_all", "承担部门");
		tableTitleMap.put("status", "审核状态");
		tableTitleMap.put("has_finished", "是否放款");
		tableTitleMap.put("summary", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listFinanceCommons1(map);
		String fileName = "公共费用报销单";
		String sheetName = "公共费用报销单";
		String title = "公共费用报销单";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 2000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 30000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 员工请假单导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listLeaveExcel", method = RequestMethod.GET)
	public  void listLeaveExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("number", "序号");
		tableTitleMap.put("person_name", "请假人");
		tableTitleMap.put("type_name", "请假类别");
		tableTitleMap.put("reason", "请假原因");
		tableTitleMap.put("leaveTime", "请假时间");
		tableTitleMap.put("destroyLeaveTime", "销假时间");
		//excel数据
		List<Map<String, String>> tList = excelService.listLeave(map);
		String fileName = "员工请假单";
		String sheetName = "员工请假单";
		String title = "员工请假单";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 2000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 6000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 项目正常报销导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listXmReimExcel", method = RequestMethod.GET)
	public  void listXmReimExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("admin_dept", "所属部门");
		tableTitleMap.put("xm_code", "项目编号");
		tableTitleMap.put("is_borrow", "类型");
		tableTitleMap.put("operation_time", "日期");
		tableTitleMap.put("reimbursement", "金额");
		tableTitleMap.put("creator", "经办人");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listXmReim(map);
		String fileName = "项目正常报销";
		String sheetName = "项目正常报销";
		String title = "项目正常报销";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 6000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 项目支付导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listXMFinanceFinishPaymentExcel", method = RequestMethod.GET)
	public  void listXMFinanceFinishPaymentExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("admin_dept", "所属部门");
		tableTitleMap.put("xm_code", "项目编号");
		tableTitleMap.put("creator", "申请人");
		tableTitleMap.put("operation_date", "放款日期");
		tableTitleMap.put("pay_value", "金额");
		tableTitleMap.put("pay_type", "对象类型");
		tableTitleMap.put("pay_to_name", "支付客户");
		tableTitleMap.put("finance_company_name", "支付账号");
		tableTitleMap.put("person", "放款人");
		tableTitleMap.put("summary", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listXMFinanceFinishPayment(map);
		String fileName = "项目支付";
		String sheetName = "项目支付";
		String title = "项目支付";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 6000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 8000);
			sheet.setColumnWidth(7, 6000);
			sheet.setColumnWidth(8, 4000);
			sheet.setColumnWidth(9, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 项目收款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listXMFinanceFinishEarnExcel", method = RequestMethod.GET)
	public  void listXMFinanceFinishEarnExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("admin_dept", "所属部门");
		tableTitleMap.put("xm_code", "项目编号");
		tableTitleMap.put("creator", "申请人");
		tableTitleMap.put("operation_time", "日期");
		tableTitleMap.put("in_money", "金额");
		tableTitleMap.put("manage_money", "管理费");
		tableTitleMap.put("customer", "来款单位");
		tableTitleMap.put("creator", "收款人");
		tableTitleMap.put("summary", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listXMFinanceFinishEarn(map);
		String fileName = "项目收款";
		String sheetName = "项目收款";
		String title = "项目收款";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 6000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 8000);
			sheet.setColumnWidth(7, 4000);
			sheet.setColumnWidth(8, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 班组还款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/gdYetAdvancesExcel", method = RequestMethod.GET)
	public  void gdYetAdvancesExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("gd_code", "工单编号");
		tableTitleMap.put("gd_name", "工单名称");
		tableTitleMap.put("fb_advances", "班组");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("sum_money", "金额");
		tableTitleMap.put("person_name", "经办人");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listGdYetAdvances(map);
		String fileName = "班组还款";
		String sheetName = "班组还款";
		String title = "班组还款";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 6000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 班组垫款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/financeGdAdvancesExcel", method = RequestMethod.GET)
	public  void financeGdAdvancesExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("gd_code", "工单编号");
		tableTitleMap.put("fb_advances", "班组");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("actual_operation_date", "放款日期");
		tableTitleMap.put("money", "金额");
		tableTitleMap.put("rate", "利率");
		tableTitleMap.put("person_name", "经办人");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listFinanceGdAdvances(map);
		String fileName = "班组垫款";
		String sheetName = "班组垫款";
		String title = "班组垫款";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 6000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 4000);
			sheet.setColumnWidth(8, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 员工借款导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/gdLoanExcel", method = RequestMethod.GET)
	public  void gdLoanExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("gd_code", "工单编号");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("actual_operation_date", "放款日期");
		tableTitleMap.put("money", "金额");
		tableTitleMap.put("person_name", "申请人");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listGdLoan(map);
		String fileName = "员工借款";
		String sheetName = "员工借款";
		String title = "员工借款";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 6000);
			sheet.setColumnWidth(3, 6000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(6, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 公共报销完成事项导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/financeOutFinanceCommonsExcel", method = RequestMethod.GET)
    public  void financeOutFinanceCommonsExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
    	//excel表头
    	Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
    	tableTitleMap.put("operation_time", "日期");
    	tableTitleMap.put("user_name", "申请人");
    	tableTitleMap.put("money", "金额");
    	tableTitleMap.put("name", "所属公司");
    	tableTitleMap.put("summary", "摘要");
    	//excel数据
    	List<Map<String, String>> tList = excelService.listFianceOutCommons(map);
    	String fileName = "公共费用报销单-确定部门";
    	String sheetName = "公共费用报销单-确定部门";
    	String title = "公共费用报销单-确定部门";
    	
    	List<Map<String,String>> list=new ArrayList<Map<String,String>>();
    	for(int i=0;i<tList.size();i++){
    		Map<String, String> k=tList.get(i);
    		list.add(k);
    	}
    	//excel基础信息
    	Map<String,String> infoMap = new HashMap<String,String>();
    	infoMap.put("fileName", fileName);
    	infoMap.put("sheetName", sheetName);
    	infoMap.put("title", title);
    	
    	Map<String,Object> model = new HashMap<String,Object>();
    	model.put("list", list);
    	model.put("infoMap", infoMap);
    	model.put("tableTitleMap", tableTitleMap);
    	try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 8000);
			sheet.setColumnWidth(4, 9000);
			sheet.setColumnWidth(5, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
	/**
	 * 公共报销完成事项导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/financeOutFinanceCommons1Excel", method = RequestMethod.GET)
	public  void financeOutFinanceCommons1Excel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("operation_time", "日期");
		tableTitleMap.put("user_name", "申请人");
		tableTitleMap.put("money", "金额");
		tableTitleMap.put("name", "所属公司");
		tableTitleMap.put("summary", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listFianceOutCommons1(map);
		String fileName = "公共费用报销单-不确定部门";
		String sheetName = "公共费用报销单-不确定部门";
		String title = "公共费用报销单-不确定部门";
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 8000);
			sheet.setColumnWidth(4, 9000);
			sheet.setColumnWidth(5, 8000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 公司账户流水导出
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "/financeCompanyLogExcel", method = RequestMethod.GET)
	public  void financeCompanyLogExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("operation_date", "时间");
		tableTitleMap.put("summary", "摘要");
		tableTitleMap.put("finance_type", "类别");
		tableTitleMap.put("before_money", "交易前金额");
		tableTitleMap.put("money", "本次发生额");
		tableTitleMap.put("afterMoney", "交易后余额");
		//excel数据
		List<Map<String,Object>> list = excelService.listFinanceCompanyLog(map);
		
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", "公司账户往来流水");
		infoMap.put("sheetName", "公司账户往来流水");
		infoMap.put("title", "公司账户往来流水");
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 8000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(4, 4000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 库存盘点
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/dbInventoryExcel", method = RequestMethod.GET)
    public  void dbInventoryExcel(HttpServletRequest request,HttpServletResponse response){
    	String inventory_code = request.getParameter("inventory_code");
    	String inventory_id = request.getParameter("inventory_id");
    	String warehouse_id = request.getParameter("warehouse_id");
    	String type = request.getParameter("type");
    	Map<String, Object> m  = (Map<String, Object>)request.getSession().getAttribute("LOGIN_USER");
    	Map<String,String> map = new HashMap<String,String>();
    	map.put("inventory_id", inventory_id);
    	map.put("warehouse_id", warehouse_id);
    	
    	//excel表头
    	Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
    	tableTitleMap.put("warehouse_name", "盘点仓库");
    	if("0".equals(type)){
    		tableTitleMap.put("customer_name", "客户名称");
    	}else if("1".equals(type)){
    		tableTitleMap.put("xm_code", "项目编号");
    		tableTitleMap.put("xm_code", "项目名称");
    	}else if("3".equals(type)){
    		tableTitleMap.put("gd_code", "工单编号");
    		tableTitleMap.put("gd_name", "工单名称");
    		tableTitleMap.put("apply_code", "采购批次");
    	}else if("4".equals(type)){
    		tableTitleMap.put("supplier_name", "供货商名称");
    	}
    	tableTitleMap.put("code", "产品编号");
    	tableTitleMap.put("name", "产品名称");
    	tableTitleMap.put("format_type", "规格/型号");
    	tableTitleMap.put("unit_name", "单位");
    	tableTitleMap.put("db_num", "帐存数量");
    	tableTitleMap.put("actually_num", "实盘数量");
    	tableTitleMap.put("different_num", "差异数量");
    	tableTitleMap.put("remark", "原因");
    	//excel数据
    	List<Map<String,String>> tList = excelService.listInventory(map);
    	if(tList.size() <= 0 || tList == null){
    		tList=	excelService.listMaterialDetail(map);
    	}
    	if(inventory_code==null||inventory_code==""){
    		inventory_code = tList.get(0).get("inventory_code");
    	}
    	String funRunId=excelService.getFlowRunId(map);
    	String fileName = String.valueOf(m.get("truename"))+"：盘点单【"+inventory_code+"】";
    	String sheetName = String.valueOf(m.get("truename"))+"：盘点单【"+inventory_code+"】";
    	String title ="";
    	if("".equals(funRunId)||funRunId==null){
    		title = String.valueOf(m.get("truename"))+":盘点单【"+inventory_code+"】";
    	}else{
    		
    		title = String.valueOf(m.get("truename"))+":盘点单【"+inventory_code+"】——流水号【"+funRunId+"】 ";
    	}
    	
    	
    	List<Map<String,String>> list=new ArrayList<Map<String,String>>();
    	for(int i=0;i<tList.size();i++){
    		Map<String, String> k=tList.get(i);
    		Object o=k.get("different_num");
    		if(o==null){
    			k.put("different_num", "");
    		}
    		Object ob=k.get("remark");
    		if(ob==null){
    			k.put("remark", "");
    		}
    		list.add(k);
    	}
    	//excel基础信息
    	Map<String,String> infoMap = new HashMap<String,String>();
    	infoMap.put("fileName", fileName);
    	infoMap.put("sheetName", sheetName);
    	infoMap.put("title", title);
    	
    	Map<String,Object> model = new HashMap<String,Object>();
    	model.put("list", list);
    	model.put("infoMap", infoMap);
    	model.put("tableTitleMap", tableTitleMap);
    	try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 6000);
			sheet.setColumnWidth(1, 6000);
			sheet.setColumnWidth(2, 6000);
			sheet.setColumnWidth(3, 4500);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 4000);
			sheet.setColumnWidth(8, 4000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
	@RequestMapping(value = "/financeCommonsDetailExcel", method = RequestMethod.GET)
	public  void financeCommonsDetailExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> queryMap  = requestParameterToMap(request);
		
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("operation_time", "日期");
		tableTitleMap.put("user_name", "申请人");
		tableTitleMap.put("name", "所属公司");
		tableTitleMap.put("is_all", "确定承担部门");
		tableTitleMap.put("type", "费用科目");
		tableTitleMap.put("dept_name", "承担部门");
		tableTitleMap.put("money", "承担金额");
		tableTitleMap.put("remark", "备注");
		//excel数据
		List<Map<String,String>> list = excelService.listFinanceCommonDetail(queryMap);
		
		String fileName = "公共费用明细";
		String sheetName = fileName;
		String title = fileName;
		
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 工单费用统计
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/gdStatisticDetailExcel", method = RequestMethod.GET)
	public  void gdStatisticDetailExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String,Object> map = requestParameterToMap(request);
		
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("gd_status_desc", "工单进度");
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("gd_code", "工单编号");
		tableTitleMap.put("gd_name", "工单名称");
		tableTitleMap.put("gd_admin_name", "工单负责人");
		tableTitleMap.put("gd_worker_name", "实施单位");
		tableTitleMap.put("gd_worker_person", "实施负责人");
		tableTitleMap.put("xm_code", "归属项目编号");
		tableTitleMap.put("xm_name", "归属项目名称");
		tableTitleMap.put("assume_worker_fee", "预算分包费");
		tableTitleMap.put("assume_material_fee", "预算材料费");
		tableTitleMap.put("worker_fee", "施工支出");
		tableTitleMap.put("material_fee", "材料支出");
		tableTitleMap.put("other_fee", "其他支出");
		//excel数据
		List<Map<String,Object>> list = excelService.listGDStatisticDetail(map);
		
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", "工单费用统计");
		infoMap.put("sheetName", "工单费用统计");
		infoMap.put("title", "工单费用统计");
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 4000);
			sheet.setColumnWidth(1, 4000);
			sheet.setColumnWidth(2, 4000);
			sheet.setColumnWidth(3, 4000);
			sheet.setColumnWidth(5, 4000);
			sheet.setColumnWidth(4, 4000);
			sheet.setColumnWidth(6, 4000);
			sheet.setColumnWidth(7, 4000);
			sheet.setColumnWidth(8, 4000);
			sheet.setColumnWidth(9, 4000);
			sheet.setColumnWidth(10, 4000);
			sheet.setColumnWidth(11, 4000);
			sheet.setColumnWidth(12, 4000);
			sheet.setColumnWidth(13, 4000);
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
   
	/**
	 * 项目--收支情况导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/xmFinanceInfoExcel", method = RequestMethod.GET)
	public  void xmFinanceInfoExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> map = requestParameterToMapUser(request);
		List<Map<String,Object>> list = excelService.listFinanceInfo(map);
		Map<String,Object> model = new HashMap<String,Object>();
    	model.put("list", list);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet("项目费用统计");
			sheet.setColumnWidth(0, 3000);
			sheet.setColumnWidth(1, 3000);
			sheet.setColumnWidth(2, 3000);
			sheet.setColumnWidth(3, 3000);
			sheet.setColumnWidth(4, 3000);
			sheet.setColumnWidth(5, 3000);
			sheet.setColumnWidth(6, 3000);
			sheet.setColumnWidth(7, 3000);
			sheet.setColumnWidth(8, 3000);
			sheet.setColumnWidth(9, 3000);
			sheet.setColumnWidth(10, 3000);
			sheet.setColumnWidth(11, 3000);
			sheet.setColumnWidth(12, 3000);
			sheet.setColumnWidth(13, 3000);
			sheet.setColumnWidth(14, 3000);
			sheet.setColumnWidth(15, 3000);
			sheet.setColumnWidth(16, 3000);
			sheet.setColumnWidth(17, 3000);
			sheet.setColumnWidth(18, 3000);
			sheet.setColumnWidth(19, 3000);
			sheet.setColumnWidth(20, 3000);
			sheet.setColumnWidth(21, 3000);
			sheet.setColumnWidth(22, 3000);
			sheet.setColumnWidth(23, 3000);
			sheet.setColumnWidth(24, 3000);
			sheet.setColumnWidth(25, 3000);
			sheet.setColumnWidth(26, 3000);
			ExcelView.buildXMExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 未付款材料清单导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/unPurchaseSupplierExcel", method = RequestMethod.GET)
    public  void unPurchaseSupplierExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> map = requestParameterToMapUser(request);
    	//excel表头
    	Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
    	tableTitleMap.put("operation_date", "产生时间");
    	tableTitleMap.put("dept_name", "部门");
    	tableTitleMap.put("xm_code", "项目编号");
    	tableTitleMap.put("xm_name", "项目名称");
    	tableTitleMap.put("gd_code", "工单编号");
    	tableTitleMap.put("gd_name", "工单名称");
    	tableTitleMap.put("supplier", "厂家名称");
    	tableTitleMap.put("money", "未付金额");
    	//excel数据
    	List<Map<String, String>> tList = excelService.listUnPurchaseSupplier(map);
    	String fileName = String.valueOf("未付款材料清单");
    	String sheetName = fileName;
    	String title = fileName;
    	
    	List<Map<String,String>> list=new ArrayList<Map<String,String>>();
    	for(int i=0;i<tList.size();i++){
    		Map<String, String> k=tList.get(i);
    		list.add(k);
    	}
    	//excel基础信息
    	Map<String,String> infoMap = new HashMap<String,String>();
    	infoMap.put("fileName", fileName);
    	infoMap.put("sheetName", sheetName);
    	infoMap.put("title", title);
    	
    	Map<String,Object> model = new HashMap<String,Object>();
    	model.put("list", list);
    	model.put("infoMap", infoMap);
    	model.put("tableTitleMap", tableTitleMap);
    	try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 3000);
			sheet.setColumnWidth(1, 3000);
			sheet.setColumnWidth(2, 3000);
			sheet.setColumnWidth(3, 3000);
			sheet.setColumnWidth(4, 3000);
			sheet.setColumnWidth(5, 3000);
			sheet.setColumnWidth(6, 3000);
			sheet.setColumnWidth(7, 3000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
	/**
	 * 已付款材料清单导出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/hasPurchasedSupplierExcel", method = RequestMethod.GET)
	public  void hasPurchasedSupplierExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> map = requestParameterToMapUser(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("operation_date", "产生时间");
		tableTitleMap.put("dept_name", "部门");
		tableTitleMap.put("xm_code", "项目编号");
		tableTitleMap.put("xm_name", "项目名称");
		tableTitleMap.put("gd_code", "工单编号");
		tableTitleMap.put("gd_name", "工单名称");
		tableTitleMap.put("supplier", "厂家名称");
		tableTitleMap.put("money", "支付金额");
		//excel数据
		List<Map<String, String>> tList = excelService.hasPurchasedSupplierExcel(map);
		String fileName = String.valueOf("已付款材料清单");
		String sheetName = fileName;
		String title = fileName;
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 3000);
			sheet.setColumnWidth(1, 3000);
			sheet.setColumnWidth(2, 3000);
			sheet.setColumnWidth(3, 3000);
			sheet.setColumnWidth(4, 3000);
			sheet.setColumnWidth(5, 3000);
			sheet.setColumnWidth(6, 3000);
			sheet.setColumnWidth(7, 3000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 已完成借款单导出列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listEmployeeLoanExcel", method = RequestMethod.GET)
	public  void listEmployeeLoanExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> map = requestParameterToMapUser(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("title", "标题");
		tableTitleMap.put("money", "金额");
		tableTitleMap.put("employee_name", "申请人");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listEmployeeLoan(map);
		String fileName = String.valueOf("已完成借款单");
		String sheetName = fileName;
		String title = fileName;
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 3000);
			sheet.setColumnWidth(1, 3000);
			sheet.setColumnWidth(2, 3000);
			sheet.setColumnWidth(3, 3000);
			sheet.setColumnWidth(4, 9000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 已完成还款单导出列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listEmployeeYetLoanExcel", method = RequestMethod.GET)
	public  void listEmployeeYetLoanExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> map = requestParameterToMapUser(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("dept_name", "所属部门");
		tableTitleMap.put("employee_name", "员工名称");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("loan_money", "借款金额");
		tableTitleMap.put("reimbursement", "还款金额");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listEmployeeReimburseme(map);
		String fileName = String.valueOf("已完成还款单");
		String sheetName = fileName;
		String title = fileName;
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 3000);
			sheet.setColumnWidth(1, 3000);
			sheet.setColumnWidth(2, 3000);
			sheet.setColumnWidth(3, 3000);
			sheet.setColumnWidth(4, 3000);
			sheet.setColumnWidth(5, 9000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 已完成分包借款导出列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/listWorkYesLoanExcel", method = RequestMethod.GET)
	public  void listWorkYesLoanExcel(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> map = requestParameterToMapUser(request);
		//excel表头
		Map<String,String> tableTitleMap = new LinkedHashMap<String,String>();
		tableTitleMap.put("fb_advances", "班组");
		tableTitleMap.put("operation_date", "日期");
		tableTitleMap.put("money", "借款款金额");
		tableTitleMap.put("fb_advances", "申请人");
		tableTitleMap.put("remark", "摘要");
		//excel数据
		List<Map<String, String>> tList = excelService.listWorkYetLoan(map);
		String fileName = String.valueOf("分包借款单");
		String sheetName = fileName;
		String title = fileName;
		
		List<Map<String,String>> list=new ArrayList<Map<String,String>>();
		for(int i=0;i<tList.size();i++){
			Map<String, String> k=tList.get(i);
			list.add(k);
		}
		//excel基础信息
		Map<String,String> infoMap = new HashMap<String,String>();
		infoMap.put("fileName", fileName);
		infoMap.put("sheetName", sheetName);
		infoMap.put("title", title);
		
		Map<String,Object> model = new HashMap<String,Object>();
		model.put("list", list);
		model.put("infoMap", infoMap);
		model.put("tableTitleMap", tableTitleMap);
		try {
			XSSFWorkbook workbook = new XSSFWorkbook();
			Sheet sheet = workbook.createSheet(infoMap.get("sheetName"));
			sheet.setColumnWidth(0, 3000);
			sheet.setColumnWidth(1, 3000);
			sheet.setColumnWidth(2, 3000);
			sheet.setColumnWidth(3, 3000);
			sheet.setColumnWidth(4, 9000);
			
			ExcelView.buildExcelDocument(model, workbook, sheet,request, response);
			ServletOutputStream out = response.getOutputStream();
			workbook.write(out);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	 @RequestMapping(value = "/historyUpload", method = RequestMethod.POST)
	    public String historyUpload(@RequestParam("uploadFile") MultipartFile uploadFile,HttpServletRequest request){
			try {
				Workbook wb = new XSSFWorkbook(uploadFile.getInputStream());
				Map<String,Object> rtMap = excelService.historyUpload(wb);
				request.setAttribute("xm_success", rtMap.get("xm_success"));
				request.setAttribute("gd_success", rtMap.get("gd_success"));
				return "excelSuccess";
				
			} catch (Exception e) {
				request.setAttribute("exceptionMsg", e.getMessage());
				return "excelError";
			}
	    }
}
